package com.example.moneygrosService;

import android.content.ContentValues;
import android.os.Parcel;
import android.os.Parcelable;

import com.example.moneygrosService.database.MoneyContract.Users;

public class User implements Parcelable {
	/**
	 * @return the bidirectional
	 */
	public boolean isBidirectional() {
		return bidirectional;
	}
	/**
	 * @param bidirectional the bidirectional to set
	 */
	public void setBidirectional(boolean bidirectional) {
		this.bidirectional = bidirectional;
	}

	// email
	private String user_id;
	// balance
	private String user_name;
	// float
	private int balance;
	// phone
	private String phone_number;
	// bluetooth-mac
	private String bluetooth_mac;
	// version
	private String version;
	// bidirectional
	private boolean bidirectional;

	public User (String id, String name, String phone, String bluetooth, String version, int balance, boolean bidirectional){
		user_id=id;
		user_name=name;
		phone_number=phone;
		bluetooth_mac=bluetooth;
		this.version=version;
		this.balance=balance;
		this.bidirectional=bidirectional;
	}
	public User (){

	}
	public String getUser_id() {
		return user_id;
	}
	public void setUser_id(String user_id) {
		this.user_id = user_id;
	}
	public String getUser_name() {
		return user_name;
	}
	public void setUser_name(String user_name) {
		this.user_name = user_name;
	}
	public String getPhone_number() {
		return phone_number;
	}
	public void setPhone_number(String phone_number) {
		this.phone_number = phone_number;
	}
	public String getBluetooth_MAC() {
		return bluetooth_mac;
	}
	public void setBluetooth_MAC(String bluetooth_mac) {
		this.bluetooth_mac = bluetooth_mac;
	}
	public String getVersion() {
		return version;
	}
	public void setVersion(String version) {
		this.version = version;
	}

	public ContentValues getContentValues(){
		ContentValues values = new ContentValues();
		values.put(Users.USER_ID, user_id);
		values.put(Users.BALANCE, balance);
		values.put(Users.BIDIRECTIONAL, bidirectional);
		values.put(Users.USER_NAME, user_name);
		values.put(Users.PHONE_NUMBER, phone_number);
		values.put(Users.VERSION, version);
		return values;
	}
	public ContentValues getProfileContentValues(){
		ContentValues values = new ContentValues();
		values.put(Users.USER_ID, user_id);
		values.put(Users.USER_NAME, user_name);
		values.put(Users.PHONE_NUMBER, phone_number);
		values.put(Users.VERSION, version);
		return values;
	}

	public int getBalance() {
		return balance;
	}

	public void setBalance(int balance) {
		this.balance = balance;
	}


	@Override
	public int describeContents() {
		return 0;
	}
	@Override
	public void writeToParcel(Parcel dest, int flags) {
		// TODO Auto-generated method stub
		dest.writeString(user_id);
		dest.writeString(user_name);
		dest.writeInt(balance);
		dest.writeString(phone_number);
		dest.writeString(version);
		dest.writeBooleanArray(new boolean[]{bidirectional});
	}

	public static final Parcelable.Creator<User> CREATOR = new Parcelable.Creator<User>()	{
		@Override
		public User createFromParcel(Parcel source)
		{
			return new User(source);
		}

		@Override
		public User[] newArray(int size)
		{
			return new User[size];
		}
	};

	public User(Parcel in) {
		this.user_id = in.readString();
		this.user_name = in.readString();
		this.balance = in.readInt();
		this.phone_number = in.readString();
		this.version = in.readString();
		boolean[] bools = new boolean[1];
		in.readBooleanArray(bools);
		this.bidirectional = bools[0];
	}
}
